package core

import "strings"

var DefaultRouter *_DefaultRouter = &_DefaultRouter{
	_map: make(map[string]Controller),
}

type _DefaultRouter struct {
	/*
	默认路由器
	 */
	_map map[string]Controller
}

func (this *_DefaultRouter) Add(urlPath string, controller Controller) {
	this._map[urlPath] = controller
}

func (this *_DefaultRouter) Match(urlPath string) Controller {
	controller, exists := this._map[strings.TrimRight(urlPath, "/")]
	if exists {
		return controller
	}
	return nil
}

func (this *_DefaultRouter) List() map[string]Controller {
	return this._map
}
